//
//  UIBarButtonItem+Tool.m
//  TTLC
//
//  Created by lxj on 15/10/15.
//  Copyright © 2015年 xj. All rights reserved.
//

#import "UIBarButtonItem+Tool.h"
@implementation UIBarButtonItem (Tool)
+(UIBarButtonItem *)itemWithTarget:(id)target Action:(SEL)action image:(NSString *)image selectedImage:(NSString *)selectedImage{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    // 设置图片
    [btn setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:selectedImage] forState:UIControlStateHighlighted];
    // 设置尺寸
    btn.size = btn.currentBackgroundImage.size;
    return [[UIBarButtonItem alloc]initWithCustomView:btn];
}
@end
